<script setup>
import BigScreen from "@/components/BigScreen.vue";
import Left from "./left/index.vue";
import Center from "./center/index.vue";
import Right from "./right/index.vue";
import { districtCockkpit } from "@/api/index";
import { onMounted, ref } from "vue";
import { useUserStore } from "@/stores/user.js";

const dataStore = useUserStore(); //获取用户信息
//入学服务
const EnrollmentServices = ref([]);
//培养服务
const TrainingServices = ref([]);
//权益服务
const RightsServices = ref([]);
//健康服务
const HealthServices = ref([]);
//毕业服务
const GraduationServices = ref([]);
//绩效kpi
const PerformanceKpi = ref([]);

onMounted(() => {
  if (dataStore.district !== "市级") {
    districtCockkpit({
      districtName: dataStore.district,
      pageNum: 1,
      pageSize: 500,
    }).then((res) => {
      let arr1 = [];
      let arr2 = [];
      let arr3 = [];
      let arr4 = [];
      let arr5 = [];
      let arr6 = [];
      if (res.code === 200) {
        const data = JSON.parse(res.data)?.data?.list;
        data.forEach((item) => {
          switch (item?.belongsmodule) {
            case "入学服务":
              arr1.push(item);
              break;
            case "培养服务":
              arr2.push(item);
              break;
            case "权益服务":
              arr3.push(item);
              break;
            case "健康服务":
              arr4.push(item);
              break;
            case "毕业服务":
              arr5.push(item);
              break;
            case "关键绩效指标（KPI）":
              arr6.push(item);
              break;
            default:
              break;
          }
        });
        console.log(arr1, "入学服务");
        console.log(arr2, "培养服务");
        console.log(arr3, "权益服务");
        console.log(arr4, "健康服务");
        console.log(arr5, "毕业服务");
        console.log(arr6, "绩效kpi");
        EnrollmentServices.value = arr1;
        TrainingServices.value = arr2;
        RightsServices.value = arr3;
        HealthServices.value = arr4;
        GraduationServices.value = arr5;
        PerformanceKpi.value = arr6;
      }
    });
  }
});
function handleCounty(name, a, b) {
  console.log("9.155", name, a, b);
  districtCockkpit({
    districtName: name,
    pageNum: 1,
    pageSize: 500,
  }).then((res) => {
    let arr1 = [];
    let arr2 = [];
    let arr3 = [];
    let arr4 = [];
    let arr5 = [];
    let arr6 = [];
    if (res.code === 200) {
      const data = JSON.parse(res.data)?.data?.list;
      data.forEach((item) => {
        switch (item?.belongsmodule) {
          case "入学服务":
            arr1.push(item);
            break;
          case "培养服务":
            arr2.push(item);
            break;
          case "权益服务":
            arr3.push(item);
            break;
          case "健康服务":
            arr4.push(item);
            break;
          case "毕业服务":
            arr5.push(item);
            break;
          case "关键绩效指标（KPI）":
            arr6.push(item);
            break;
          default:
            break;
        }
      });
      console.log(arr1, "入学服务");
      console.log(arr2, "培养服务");
      console.log(arr3, "权益服务");
      console.log(arr4, "健康服务");
      console.log(arr5, "毕业服务");
      console.log(arr6, "绩效kpi");

      EnrollmentServices.value = arr1;
      TrainingServices.value = arr2;
      RightsServices.value = arr3;
      HealthServices.value = arr4;
      GraduationServices.value = arr5;
      PerformanceKpi.value = arr6;
    } else {
      EnrollmentServices.value = [];
      TrainingServices.value = [];
      RightsServices.value = [];
      HealthServices.value = [];
      GraduationServices.value = [];
      PerformanceKpi.value = [];
    }
  });
  if (name === "石柱土家族自治县" || name === "永川区") {
  }
}
</script>

<template>
  <BigScreen title="渝悦·惠学生">
    <template #left>
      <Left
        :EnrollmentServices="EnrollmentServices"
        :TrainingServices="TrainingServices"
        :RightsServices="RightsServices"
      ></Left>
    </template>
    <template #center>
      <Center :PerformanceKpi="PerformanceKpi" @details="handleCounty"></Center>
    </template>
    <template #right>
      <Right
        :HealthServices="HealthServices"
        :GraduationServices="GraduationServices"
      ></Right>
    </template>
  </BigScreen>
</template>
